﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO_QLNS;

namespace ADO_QLNS
{
    class OrderDetailADO : QLNS_ADO
    {
        OrderDetailDTO _DTO;

        public override string InsertString(TransferObject dto)
        {
            _DTO = (OrderDetailDTO)dto;
            string sql = "INSERT INTO OrderDetail(BookID, Quantity, Price, OrderID) VALUES({0},{1},{2},{3})";
            return String.Format(sql, _DTO.BookID, _DTO.Quantity, _DTO.Price, _DTO.OrderID);
        }

        public override string UpdateString(TransferObject dto)
        {
            _DTO = (OrderDetailDTO)dto;
            string sql = "Update OrderDetail SET Quantity ={0} WHERE OrderDetailID = {1})";
            return String.Format(sql, _DTO.Quantity, _DTO.OrderDetailID);
        }

        public override string DeleteString(TransferObject dto)
        {
            _DTO = (OrderDetailDTO)dto;
            string deleteCmd = "DELETE FROM OrderDetail WHERE OrderDetailID = {0}";
            return String.Format(deleteCmd, _DTO.OrderDetailID);
        }

        protected override object GetDataFromDataRow(System.Data.DataTable dt, int i)
        {
            throw new NotImplementedException();
        }
    }
}
